package cn.gok.day6.controller;

import cn.gok.day6.entity.Student;
import cn.gok.day6.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    @Autowired
    private StudentService studentService;
    @RequestMapping("/findAll")
    public List<Student> findAllStudent(){
        return studentService.list(null);
    }
    @RequestMapping("/findById")
    public Student findStudentById(@RequestParam Long id){
        return studentService.getById(id);
    }
    @RequestMapping("/save")
    public boolean saveStudent(@RequestBody Student student){
        return studentService.save(student);
    }
    @RequestMapping("/update")
    public boolean updateStudentById(@RequestBody Student student){
        return studentService.updateById(student);
    }
    @RequestMapping("/removById")
    public boolean removStudentById(@RequestParam Long id){
        return studentService.removeById(id);
    }
    @RequestMapping("/removeByIds")
    public boolean removeStudentByIds(@RequestBody List<Integer> ids){
        return studentService.removeByIds(ids);
    }
}
